"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
console.log('-----1.简单工厂模式-------');
//1.1 简单工厂模式
//咖啡类的抽象类基类
var Coffe = /** @class */ (function () {
    function Coffe(name) {
        this.name = name;
        this.getCoffe(this.name);
    }
    ;
    Coffe.prototype.getCoffe = function (name) {
        console.log('要制作的咖啡是：', name);
    };
    return Coffe;
}());
;
var AmriCoffe = /** @class */ (function (_super) {
    __extends(AmriCoffe, _super);
    function AmriCoffe(name) {
        return _super.call(this, name) || this;
    }
    ;
    return AmriCoffe;
}(Coffe));
var LatteCoffe = /** @class */ (function (_super) {
    __extends(LatteCoffe, _super);
    function LatteCoffe(name) {
        return _super.call(this, name) || this;
    }
    ;
    return LatteCoffe;
}(Coffe));
var FlowerCoffe = /** @class */ (function (_super) {
    __extends(FlowerCoffe, _super);
    function FlowerCoffe(name) {
        return _super.call(this, name) || this;
    }
    ;
    return FlowerCoffe;
}(Coffe));
;
// 简单工厂类
var FactorySimple = /** @class */ (function () {
    function FactorySimple(name) {
        console.log('顾客要制作的coffe是=》', name);
    }
    ;
    FactorySimple.order = function (coffeName) {
        switch (coffeName) {
            case '美式咖啡':
                return new AmriCoffe(coffeName);
                break;
            case '拿铁咖啡':
                return new LatteCoffe(coffeName);
                break;
            case '花式咖啡':
                return new FlowerCoffe(coffeName);
                break;
            default:
                return 'sorry!我们这里没有这种咖啡！';
        }
    };
    return FactorySimple;
}());
;
// 测试简单工厂模式
var factorySimpel = new FactorySimple('111');
var res = FactorySimple.order('拿铁咖啡');
console.log(res);
window.$ = function (selector) {
    return new JQuery(selector);
};
var JQuery = /** @class */ (function () {
    function JQuery(selector) {
        var _this = this;
        var elements = [].slice.call(document.querySelectorAll(selector));
        // console.log(elements,selector)；
        this.length = elements.length ? elements.length : 0;
        elements.forEach(function (item, i) {
            _this[i] = item;
        });
    }
    JQuery.prototype.html = function (htmlText) {
        if (htmlText) {
            //如果有值就是赋值
            for (var i = 0; i < this.length; i++) {
                this[i].innerHTML = htmlText;
            }
            ;
            console.log('此时是html方法赋值状态');
        }
        else {
            //如果没有值就是取值
            console.log('此时是html方法取值状态');
            return this[0];
        }
    };
    return JQuery;
}());
;
window.$('.box').html('000999');
// 总结：简单工厂模式就是函数里返回类的实例
